#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


//void Widget::on_dateTimeEdit_dateTimeChanged(const QDateTime &dateTime)
//{
//    qDebug() << dateTime;
//}

void Widget::on_pushButton_clicked()
{
    // 1、获取旧时间和新时间的值
    QDateTime time1 = ui->dateTimeEdit->dateTime();
    QDateTime time2 = ui->dateTimeEdit_2->dateTime();

    // 2、相减获取差值
    int sec = time1.secsTo(time2);
    int day = (sec / 3600) / 24;
    int hour = (sec / 3600) % 24;
    int min = (sec / 60) % 60;
    qDebug() << day << hour << min;
}
